package com.quiz.bis.controller;

import com.quiz.bis.domain.bo.PaperStrategyBO;
import com.quiz.bis.domain.model.PaperStrategy;
import com.quiz.bis.domain.vo.PaperStrategyVO;
import com.quiz.bis.service.IPaperStrategyService;
import com.quiz.common.core.controller.BaseController;
import com.quiz.common.core.domain.R;
import com.quiz.common.mybatis.core.page.PageQuery;
import com.quiz.common.mybatis.core.page.TableDataInfo;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 组卷策略管理
 *
 * @author ahuan
 */
@RestController
@RequestMapping("paper2/strategy")
@Tag(name = "组卷策略管理")
@RequiredArgsConstructor
public class PaperStrategyController extends BaseController {

    private final IPaperStrategyService strategyService;

    /**
     * 分页查询策略列表
     */
    @GetMapping("/list")
    public TableDataInfo<PaperStrategy> list(String name, Integer strategyType, PageQuery pageQuery) {
        return strategyService.pageStrategyList(pageQuery, name, strategyType);
    }

    /**
     * 获取策略详情
     */
    @GetMapping("/{strategyId}")
    public R<PaperStrategy> detail(@PathVariable Long strategyId) {
        return strategyService.getStrategyDetail(strategyId);
    }

    /**
     * 创建策略
     */
    @PostMapping
    public R<Long> create(@Validated @RequestBody PaperStrategyBO strategyBO) {
        return strategyService.createStrategy(strategyBO);
    }

    /**
     * 更新策略
     */
    @PutMapping
    public R<Void> update(@Validated @RequestBody PaperStrategyBO strategyBO) {
        return strategyService.updateStrategy(strategyBO);
    }

    /**
     * 删除策略
     */
    @DeleteMapping("/{strategyId}")
    public R<Void> delete(@PathVariable Long strategyId) {
        return strategyService.deleteStrategy(strategyId);
    }
}